﻿using System;
using System.Collections.Generic;
using System.Text;
using Webcar.Interface;
using System.Data;
using ToolsLayer;
using BusinessEntity;
using Webcar.BLL;
namespace Webcar.DAL.SqlServer
{
    public class Car:ICar   
    {
        /*private readonly string ListSql = "select a.*,case isnull(b.infoid,'null') when 'null' then 0 else 1 end is_read "+
            " from v_bs_car_record a left join infolist b " +
           " on a.car_no=b.infoid and b.tablename='{0}' where a.is_use in ({1}) and a.dept_code in "+
           " (select dept_code from bs_man_dept where man_code='{2}')";
        */
        private readonly string ListSql = "select a.*,right(a.record_no,1) record_end_no from v_bs_car_record a " +
           " where a.is_use in ({0}) and a.dept_code in " +
           " (select dept_code from bs_man_dept where man_code='{1}')";

        #region ICar 成员
        
        public string GetListSql(string is_use_flag)
        {
            //InfoChecker ic = new InfoChecker();
            //string tablename = ic.GetTableName(InfoCheckType.Car);
            return string.Format(ListSql, is_use_flag, CurrentUser.LoginUserID);
        }

        public DataSet GetInsureSqlByCar(string carno)
        {
            string sql = "select insure_no,insure_no2,car_no,record_no,convert(varchar(10),start_date,120) start_date,"+
                " convert(varchar(10),end_date,120) end_date,jqx_no,case when end_date<getdate() then '已到期' else '执行中' end zt "+
                " from dbo.BS_INSURE where car_no = '"+carno+"'";
            return DB.ExecuteDataset(sql);
        }
        #endregion
    }
}
